package com.cofiroute.ldap;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Vector;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import com.cofiroute.annuaire.SiteProfil;

public class CofiUserDetails implements UserDetails {

	/**
   * 
   */
	private static final long serialVersionUID = 371613300108196515L;
	private GrantedAuthority[] authorities = null;
	private String password = null;
	private String username = null;
	private Vector mlstProfiles = null;
	private LinkedHashMap mlstRessourcesProfil = null;
	private LinkedHashMap mlstApplication = null;

	private LinkedHashMap<SiteProfil, SiteProfil> mlstSiteProfil = null;

	public CofiUserDetails(GrantedAuthority[] authorities, String username, String password, Vector rlstProfiles, LinkedHashMap rlstRessourcesProfil, LinkedHashMap rlstApplication,
			LinkedHashMap<SiteProfil, SiteProfil> rlstSiteProfil) {

		super();
		this.authorities = authorities;
		this.password = password;
		this.username = username;
		this.mlstProfiles = rlstProfiles;
		this.mlstRessourcesProfil = rlstRessourcesProfil;
		this.mlstApplication = rlstApplication;

		this.mlstSiteProfil = rlstSiteProfil;// ..................................................
	}

	public Collection<GrantedAuthority> getAuthorities() {
		Collection<GrantedAuthority> authorities = Arrays.asList(this.authorities);
		return authorities;
	}

	public String getPassword() {
		return this.password;
	}

	public String getUsername() {
		return this.username;
	}

	public Vector getProfiles() {
		return this.mlstProfiles;
	}

	public LinkedHashMap getApplication() {
		return this.mlstApplication;
	}

	public boolean isAccountNonExpired() {
		return true;
	}

	public boolean isAccountNonLocked() {
		return true;
	}

	public boolean isCredentialsNonExpired() {
		return true;
	}

	public boolean isEnabled() {
		return true;
	}

	public LinkedHashMap getRessourcesProfil() {
		return mlstRessourcesProfil;
	}

	public void setRessourcesProfil(LinkedHashMap rlstRessourcesProfil) {
		this.mlstRessourcesProfil = rlstRessourcesProfil;
	}

	public LinkedHashMap<SiteProfil, SiteProfil> getSiteProfil() {
		return mlstSiteProfil;
	}

	public void setSiteProfil(LinkedHashMap<SiteProfil, SiteProfil> rlstSiteProfil) {
		this.mlstSiteProfil = rlstSiteProfil;
	}

}